<script>
	import config from 'tool/common.js';
	import {
		change_info
	} from '@/tool/http.js';
	export default {
		globalData: {
			identify:'1',		//身份 默认1货主  2司机
			header_top: '',
			header_height: '',
			isIos: uni.getSystemInfoSync().osName == 'ios' ? true : false,
			lat: '',
			lng: '',
			mapKey:'CYCBZ-FP2WZ-TNJXE-ZFJJR-N22Q6-ONBCR',
		},
		onLaunch: function() {
			var equipment = uni.getMenuButtonBoundingClientRect();
			this.globalData.header_top = equipment.top + 5;
			this.globalData.header_height = equipment.height;
			
			let identify = uni.getStorageSync('use_identify') ? uni.getStorageSync('use_identify') : '1';
			uni.setStorageSync('use_identify',identify);
			this.globalData.identify = identify;
		},
		onShow: function() {
			if(uni.getStorageSync('use_identify') == '2' && uni.getStorageSync('uid')){
				uni.startLocationUpdate({
					type:'gcj02',
					success: (locate) => {
						console.log(locate);
						if(locate.errMsg == "startLocationUpdate:ok"){
							uni.onLocationChange(async(res)=>{
								console.log('更新的位置',res);
								if(res.latitude && res.longitude){
									var oldPos = uni.getStorageSync("oldPos");
									if(!oldPos || oldPos != (res.latitude+'-'+res.longitude)){
										var res = await change_info({
											memberId:uni.getStorageSync('uid'),
											lat:res.latitude,
											lng:res.longitude
										});
										if(res){
											uni.setStorageSync('oldPos',res.latitude+'-'+res.longitude);
										}
									}
								}
							})
						}
					},
					fail:(err)=>{
						console.log(err);
					}
				})
			}
		},
		onHide: function() {
			
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import "uview/index.scss";
	page {
		width: 100%;
		height: 100%;
		font-size: 14px;
		background: #F6F6F6;
		color: #333333;
	}
	.pageHead{
		width:100%;
		padding:0 12px 5px;
		box-sizing:border-box;
		.pageTit{
			flex:1;
			text-align: center;
			font-size:16px;
		}
	}
	button {
		background: none;
		padding: 0;
		margin: 0;
		border: none;
		line-height: normal;
		font-size: 14px;
	}
	button::after {
		border: none;
	}
	image {
		height: auto;
		width: 100%;
		border-radius: 4px;
	}
	input,
	textarea {
		display: block;
		width: 100%;
	}
	.imgPublic {
		font-size: 0;
		overflow: hidden;
	}
		
	.dFlex {
		display: flex;
	}
		
	.jStart_aStart {
		justify-content: flex-start;
		align-items: flex-start;
	}
		
	.jStart_aCenter {
		justify-content: flex-start;
		align-items: center;
	}
		
	.jStart_aEnd {
		justify-content: flex-start;
		align-items: flex-end;
	}
		
	.jAround_aStart {
		justify-content: space-around;
		align-items: flex-start;
	}
		
	.jAround_aCenter {
		justify-content: space-around;
		align-items: center;
	}
		
	.jAround_aEnd {
		justify-content: space-around;
		align-items: flex-end;
	}
		
	.jCenter_aStart {
		justify-content: center;
		align-items: flex-start;
	}
		
	.jCenter_aCenter {
		justify-content: center;
		align-items: center;
	}
		
	.jCenter_aEnd {
		justify-content: center;
		align-items: flex-end;
	}
		
	.jEnd_aStart {
		justify-content: flex-end;
		align-items: flex-start;
	}
		
	.jEnd_aCenter {
		justify-content: flex-end;
		align-items: center;
	}
		
	.jEnd_aEnd {
		justify-content: flex-end;
		align-items: flex-end;
	}
	.jBetween_aStart {
		justify-content: space-between;
		align-items: flex-start;
	}
	.jBetween_aCenter {
		justify-content: space-between;
		align-items: center;
	}
	.jBetween_aEnd {
		justify-content: space-between;
		align-items: flex-end;
	}
	.flexDirection {
		flex-direction: column;
	}
	.fWap {
		flex-wrap: wrap;
	}
	.seat {
		height: 50px;
	}
	.zz {
		width: 100%;
		height: 100%;
		background: rgba(0, 0, 0, 0.5);
		position: fixed;
		top: 0;
		left: 0;
		z-index: 100;
	}
	.empty {
		width: 50% !important;
		margin: 80rpx auto 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	view::-webkit-scrollbar {
	    display: none; /* Chrome Safari */
	}
	.ios_safe{
		padding-bottom:env(safe-area-inset-bottom)!important;
	}
</style>